package cn.tedu.doc_sys.repo.impl;

import cn.tedu.doc_sys.pojo.vo.RegisterStandardVO;
import cn.tedu.doc_sys.repo.IRegisterRedisRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.io.Serializable;


@Slf4j
@Repository
public class RegisterRedisRepository implements IRegisterRedisRepository {
    @Autowired
    RedisTemplate<String, Serializable> redisTemplate;

    public RegisterRedisRepository() {
        log.debug("创建处理缓存的数据访问对象：RegisterRedisRepositoryImpl");
    }

    private String getItemKey(Long id){return REGISTER_KEY_PREFIX+id;}

    @Override
    public void save(RegisterStandardVO registerStandardVO){
        log.debug("准备向Redis中写入数据:{}",registerStandardVO);
        String key = getItemKey(registerStandardVO.getId());
        redisTemplate.opsForValue().set("register"+registerStandardVO.getId(),registerStandardVO );
    }




}
